using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;

namespace BUS
{
   public  class tbCTDonHangBUS
    {
        public static void Insert(tbCTDonHang ctdh)
        {
            tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
            ctdhDAL.Insert(ctdh);

        }
        public static void Uptate(tbCTDonHang ctdh)
        {
            tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
            ctdhDAL.Update(ctdh);

        }
        public static void Delete(int iD)
        {
            tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
            ctdhDAL.Delete(iD);
        }
        public static tbCTDonHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
            return ctdhDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTDonHangCollection GetAll()
        {
            int total = 0;
            tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
            return ctdhDAL.Get("where 1=1", 0, 0,
            tbCTDonHangColumns.MaCTHD.ToString(),
            "ASC", out total);
        }
        public static tbCTDonHang GetByID(int iD)
        {
            int total = 0;
            tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
            tbCTDonHangCollection CTDonHangCollection = ctdhDAL.Get("where " +
            tbCTDonHangColumns.MaCTHD .ToString() + "=" + iD.ToString(),
            0, 0, tbCTDonHangColumns.MaCTHD .ToString(), "ASC", out total);
            if (CTDonHangCollection.Count > 0)
                return CTDonHangCollection[0];
            return null;
        }

    }
}
